<script type="text/javascript">
function facultyEdit(facultyId, facultyFile){
	$("#hidId").val(facultyId);
	$("#hidType").val("edit");
	$("#hidFile").val(facultyFile);
	$("#faculty_form").prop("action", "/it_center/Faculties/faculty_edit");
	return $("#faculty_form").submit();
}

function facultyDelete(facultyId, facultyFile){
	$("#hidId").val(facultyId);
	$("#hidType").val("delete");
	$("#hidFile").val(facultyFile);
	return $("#faculty_form").submit();
}
</script>

<form id="faculty_form" method="post">	
	<input type="hidden" name="facultyId" id="hidId"/>
	<input type="hidden" name="submitType" id="hidType"/>
	<input type="hidden" name="facultyFile" id="hidFile"/>
</form>

<section id="content" class="news-b"> 
	<a class="regist" style="margin-left:0px;" href="/it_center/Faculties/faculty_add">Thêm giảng viên</a>
	<?php foreach ($faculties as $faculty): ?>
		<article> 
			<header> 
				<figure class="image-b"> 
					<img src="/it_center/faculty/<?php echo $faculty['Faculty']['m_fct_image'];?>" alt="Placeholder" width="211" height="241">
				</figure>
				<h2><?php echo $faculty['Faculty']['m_fct_name'];?></h2>
				<p>
					Điện thoại: <?php echo $faculty['Faculty']['m_fct_tel'];?>
				</p>
				<p>
					Mobile: <?php echo $faculty['Faculty']['m_fct_mobile'];?>
				</p>
				<p>
					Email: <?php echo $faculty['Faculty']['m_fct_email'];?>
				</p>
				<p>
					File: <?php echo $faculty['Faculty']['m_fct_image'];?>
				</p>
				<p>
					Chuyên ngành phụ trách: 
					<?php 
						$subjects = $faculty['Subject'];
						$outStr = "";
						foreach ($subjects as $subject):
							If ($outStr != ""){
								$outStr = $outStr . " , ";
							}
							$outStr = $outStr . $subject['sub_name'];
						endforeach;
						echo $outStr;
					?>
				</p>
			</header>
			<p>	
				<?php echo $faculty['Faculty']['m_fct_descript'];?>
			</p>
        	<a class="edit" onclick="facultyEdit(<?php echo $faculty['Faculty']['m_fct_id']; ?>, '<?php echo $faculty['Faculty']['m_fct_image'];?>')">Chỉnh sửa</a>
        	<a class="delete" onclick="facultyDelete(<?php echo $faculty['Faculty']['m_fct_id']; ?>, '<?php echo $faculty['Faculty']['m_fct_image'];?>')">Xóa</a>
	</article> 
	<?php endforeach; ?>
	<?php unset($faculties); ?>
</section>